package com.mallcai.bigdata.ladon.controller.peekdata.form;

import com.mallcai.bigdata.ladon.controller.BaseForm;
import com.mallcai.bigdata.ladon.dpl.entity.BaseEntity;
import com.mallcai.bigdata.ladon.dpl.entity.peekdata.ImportRecord;
import com.mallcai.bigdata.ladon.dpl.entity.peekdata.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.validation.constraints.NotNull;

/**
 * @author feixy
 * @version 1.0
 * @date 2019-07-12 14:51
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class DataImportForm extends BaseForm {

    @NotNull(message = "数据源类型不能为空", groups = {ImportCheck.class})
    private String datasourceType;
    @NotNull(message = "数据源不能为空", groups = {ImportCheck.class})
    private Long datasourceId;

    @NotNull(message = "导入表不能为空", groups = {ImportCheck.class})
    private String tableName;

    @NotNull(message = "文件名不能为空", groups = {ImportCheck.class})
    private String fileName; //上传的文件名

    private Integer partitioned; // 是否分区, 1是0否

    private Integer overwrited; // 是否覆盖, 1是0否

    public interface ImportCheck{

    }


    public ImportRecord toEntity() {
        ImportRecord m = new ImportRecord();
        BeanUtils.copyProperties(this, m);
        //分区名
        return m;
    }

}
